#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>

const float pi = 3.1415926535;

inline float sqr(float x)
{
	return x*x;
}

inline float randpi2() // random in (0, pi/2)
{
	return pi/2*rand()/RAND_MAX;
}

inline bool D(float x,float t) // is (x,t) inside D?
{
	return (x<t) && (sin(t) < 1/cos(x) - sin(x));
}


int main(void)
{
	srand(time(NULL)); // randomize

	float k;
	printf("Input precision (k):");
	scanf("%f",&k);

	int n = sqr(2*1.36*100/(k * sqrt(12)));
	printf("Iterations: %d\n",n);
	int count=0;
	float x,t;
	for(int i=0;i<n;i++)
	{
		x = randpi2();
		t = randpi2();
		if(D(x,t)) count++;
	}
	float res = sqr(pi)/4*count/n;
	printf("Result: %f\n",res);
}
